<?PHP
date_default_timezone_set("Asia/Chongqing");
require_once("common.php");
require_once("taobaosdk/TopSdk.php");

function GetItemInfo($itemid)
{
	$c = new TopClient;
	$c->appkey = "12351945";
	$c->secretKey = "e2218a20f1bd93de0952daed50d9ad3d";
	$req = new ItemGetRequest;
	$req->setFields("detail_url,title,nick,cid,pic_url,num,price");
	$req->setNumIid($itemid);
	$resp = $c->execute($req);
	
	if ($resp->getName() == "item_get_response" && isset($resp->item))
	{
		$str = "{\"code\":1";
		$str .= ",\"detail_url\":\"".$resp->item[0]->detail_url."\"";
		$str .= ", \"pic_url\":\"".$resp->item[0]->pic_url."\"";
		$str .= ", \"title\":\"".$resp->item[0]->title."\"";
		$str .= ", \"price\":\"".$resp->item[0]->price."\"";

		$str .= "}";
		return $str;
	}
			
	return "{\"code\":0}";
}

//
$itemid = CheckUrlParamNoDie("itemid");
if ($itemid != "")
	echo GetItemInfo($itemid);

?>